package com.dao.imp;

import com.entity.Address;
import com.entity.GoodStatus;
import com.util.DBConn;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Mathison
 * @Title: FindAddress
 * @Package: com.dao.imp
 * @Description: TODO
 * @date 2021/11/25 21:58
 **/
public class FindAddress {
    public static List<Address> getAddress(String sql){
        List<Address> addressList = new ArrayList<>();
        try{
            DBConn.init();
            ResultSet resultSet = DBConn.selectSql(sql);
            while (resultSet.next()){
                Address address = new Address();
                address.setUser_id(resultSet.getInt("user_id"));
                address.setAddress_id(resultSet.getInt("address_id"));
                address.setReceiver(resultSet.getString("receiver"));
                address.setFull_address(resultSet.getString("full_address"));
                address.setCity(resultSet.getString("city"));
                address.setProvince(resultSet.getString("province"));
                address.setReceiver_phoneNum(resultSet.getString("receiver_phoneNum"));
                address.setPostCode(resultSet.getInt("postCode"));
                addressList.add(address);
            }
//            DBConn.closeConn();
        }catch (SQLException e){
            e.printStackTrace();
        }
        return addressList;
    }
}
